﻿using ArcEngine.Interfaces;
using ArcEngine;
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using ArcEngine.Resources;
using System.Xml;
using ArcEngine.Graphics;

namespace DungeonEye
{

	/// <summary>
	/// This class represents a monster in the dungeon
	/// </summary>
	public class Dwarf : Monster
	{
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="name">Name of the dwarf</param>
		/// <param name="lvl">Initial level</param>
		public Dwarf(string name, Maze lvl) : base(name, lvl)
		{
			Tileset = ResourceManager.GetTileSet("Dwarf");
			Tileset.Zoom = new SizeF(2.0f, 2.0f);

		}




		/// <summary>
		/// Draw the monster
		/// </summary>
		public override void Draw(Point offset)
		{
			if (Tileset == null)
				return;

			// Monster not visible to the team
			if (!Team.CanSee(Maze, Location))
				return;
			
			Tileset.Bind();
			Tileset.Draw(0, new Point(100, 100));


			Video.DrawText(new Point(300, 350), Team.Distance(Location).ToString());
			
		}


		/// <summary>
		/// Update the logic
		/// </summary>
		public override void Update()
		{
			ViewField pov = new ViewField(Maze, Location, Facing);

		}



		#region IO

		/// <summary>
		/// 
		/// </summary>
		/// <param name="filename"></param>
		/// <returns></returns>
		public bool Load(XmlNode xml)
		{

			// For each nodes, process it
			foreach (XmlNode node in xml)
			{
				if (node.NodeType == XmlNodeType.Comment)
					continue;


				switch (node.Name.ToLower())
				{
					case "location":
					{
						Location = new Point(int.Parse(node.Attributes["x"].Value), int.Parse(node.Attributes["y"].Value));
					}
					break;


				}
			}



			return true;
		}



		/// <summary>
		/// 
		/// </summary>
		/// <param name="filename"></param>
		/// <returns></returns>
		public bool Save(string filename)
		{
			return false;

		}


		#endregion



		#region properties


		#endregion
	}
}
